import { getStoreHouseAPI } from '@/api/hazardousChemicals.js'

const hjuser = {
  namespaced: true,
  state: {
    activeItem: 0, // 个人中心侧栏当前选项index
    chooseList: [1, 2], // 加入申请的数据
    chemicalData: [], // 危化品数据
    standardSubstanceData: [], // 标准物质数据
    reagentData: [], // 试剂耗材数据
    searchId: '', // 预约信息领用信息 查询ID
    systemSearchInfoId: '',// 信息跳转id
    allLabs: [],//所有实验室
    allUsers: [],//所有用户
  },
  mutations: {
    updatedActiveItem(state, active) {
      state.activeItem = active
    },
    updatedChooseList(state, active) {
      state.chooseList = active
    },
    updatedStoreHouse (state, infos) {
      state.reagentData = infos[0]
      state.standardSubstanceData = infos[1]
      state.chemicalData = infos[2]
    },
    updatedsearchId(state, active) {
      state.searchId = active
    },
    updatedsystemSearchInfoId(state, active) {
      state.systemSearchInfoId = active
    },
    setAllLabs (state, labs) {
      state.allLabs = labs
    },
    setAllUsers (state, users) {
      state.allUsers = users
    }

  },
  actions: {
    async getStoreHouse({ commit }) {
      const res1 = await getStoreHouseAPI(1)
      const res2 = await getStoreHouseAPI(2)
      const res3 = await getStoreHouseAPI(3)
      commit('updatedStoreHouse', [res1.data, res2.data, res3.data])
    }
  }
}

export default hjuser
